function [rows, cols] = maxN(X, N)
inds = zeros(N,1);
tmpX = X(:);
for i=1:N
  [~, inds(i)] = max(tmpX);
  tmpX(inds(i)) = -inf;
end
[rows, cols] = ind2sub(size(X), inds);
end

